package com.example.thread;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ZhangLiang
 * @Date: 2021/07/03/10:46
 * @Description: synchronized单例
 */
public class SynchronizedDemo {
    public volatile  static SynchronizedDemo uniqueInstance;

    public SynchronizedDemo() {
    }

    public static SynchronizedDemo getUniqueInstance() {
        if (uniqueInstance==null){
            synchronized (SynchronizedDemo.class){
              if (uniqueInstance==null){
                  uniqueInstance=new SynchronizedDemo();
              }
            }
        }
        return uniqueInstance;
    }
}
